package com.adjaisd.scarecrow.service;

import com.adjaisd.scarecrow.dto.DeviceInfoDTO;
import com.adjaisd.scarecrow.dto.QuotaDTO;
import com.adjaisd.scarecrow.dto.QuotaInfo;
import com.adjaisd.scarecrow.entity.Quota;
import com.adjaisd.scarecrow.vo.DeviceQuotaVO;
import com.adjaisd.scarecrow.vo.Pager;
import com.adjaisd.scarecrow.vo.QuotaAlarmVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author adjaisd
 * @since 2022-03-24
 */
public interface QuotaService extends IService<Quota> {

    boolean existQuotaByNumberUID(Long number, long userId);

    List<Quota> getQuotaListByUID(Long userId);

    Quota getQuotaByID(Long quotaId, Long userId);

    List<String> getAllSubject();

    Quota getQuota(Long number, String name, String subject, String valueKey, String valueType, Long userId);

    boolean existSubject(String subject);

    boolean addQuota(Quota quota);

    boolean delQuota(Long number, String name, String subject, String valueKey, String valueType, Long userId);


    // ----------------

    // 分析数据报
    DeviceInfoDTO analysis(String topic, Map<String, Object> payloadMap);

    void saveQuotaToInflux(List<QuotaDTO> quotaDTOList);

    List<QuotaInfo> getLastQuotaList(Long deviceId);


    Pager<QuotaAlarmVO> queryQuotaAlarmPage(long userId, long page, long pageSize, String name, String number);

    Pager<DeviceQuotaVO> queryDeviceQuotaPage(long userId, long page, long pageSize, String number, String tag, int state);

    // 获取数值型指标列表
    IPage<Quota> queryNumberQuota(Long userId, Long page, Long pageSize);

    Boolean existQuota(Long userId, String quotaName, String unit);

}
